﻿using System;
using System.Collections.ObjectModel;
using System.ServiceModel;
using Conducido.BizTalkOppSvc.Services.Contracts;
using Conducido.BizTalkOppSvc.Services.Contracts.BtsTypes;

namespace Conducido.BizTalkOppSvc.Services.Implementation
{
    [ServiceBehavior(Namespace = "http://schemas.conducido.nl/BizTalkOpSuite/BtsOperationInfo/2012/01")]
    public class BtsOperationInfo: IBtsOperationInfo
    {
        public BtSysStatus ApplicationStatus(string name)
        {
            BtsQuery btsQuery = new BtsQuery();
            return btsQuery.ApplicationStatus(name);
        }

        public Collection<BtApplication> Applications()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Retrieves al receivelocations for a certain BizTalk Applicatoin
        /// </summary>
        /// <param name="application"></param>
        /// <returns>Return a collection of <see cref="BtReceiveLocation"/></returns>
        public Collection<BtReceiveLocation> RetrieveAllReceivelocations(string application)
        {
            if (string.IsNullOrWhiteSpace(application))
            {
                throw new ArgumentNullException(application);
            }
            BtsQuery btsQuery = new BtsQuery();
            return btsQuery.GetAllReceiveLocations(application);
        }

        /// <summary>
        /// Retrieves al sendports for specific BizTalk application
        /// </summary>
        /// <param name="application"></param>
        /// <returns></returns>
        public Collection<BtSendPort> RetrieveAllSendPorts(string application)
        {
            BtsQuery btsQuery = new BtsQuery();
            return btsQuery.GetAllSendPorts(application);
        }


        /// <summary>
        /// Get all the service / running instances
        /// </summary>
        /// <returns></returns>
        public Collection<BtServiceInstance> RetrieveServiceInstances()
        {
            var query = new BtsQuery();
            return query.GetServiceInstances("");
        }
    }
}
